<?php
    require('common.php');
        
    $db = new Database();
    $user = getUser($db);
    
    // Error check
    if($user['group'] < 2) {
        redirect('index.php');
        exit();
    }
    checkCsrfGuard();
    if(!isset($_POST['id']))
        throw new Exception('Bad request.');
        
    // Delete the user
    $db->query('DELETE FROM '.config('DB_PREFIX').'users '.
        'WHERE id='.intval($_POST['id']));
    
    // Success
    redirect('users.php');
?>